@(milestone: Option[gitbucket.core.model.Milestone],
  repository: gitbucket.core.service.RepositoryService.RepositoryInfo)(implicit context: gitbucket.core.controller.Context)
@import gitbucket.core.view.helpers
@gitbucket.core.html.main(s"Milestones - ${repository.owner}/${repository.name}"){
  @gitbucket.core.html.menu("milestones", repository){
    @if(milestone.isEmpty){
      <h4>New milestone</h4>
      <div class="muted">Create a new milestone to help organize your issues and pull requests.</div>
    }
    <hr style="margin-top: 12px; margin-bottom: 18px;" class="fill-width"/>
    <form method="POST" action="@helpers.url(repository)/issues/milestones/@if(milestone.isEmpty){new}else{@milestone.get.milestoneId/edit}" validate="true" autocomplete="off">
      <fieldset class="form-group">
        <input type="text" id="title" name="title" class="form-control" style="width: 500px;" value="@milestone.map(_.title)" placeholder="Title" aria-label="Title"/>
        <span id="error-title" class="error"></span>
      </fieldset>
      <fieldset class="form-group">
        <label for="description" class="strong">Description</label>
        <textarea id="description" name="description" class="form-control" style="width: 500px; height: 150px;">@milestone.map(_.description)</textarea>
        <span id="error-description" class="error"></span>
      </fieldset>
      <fieldset class="form-group">
        <label for="dueDate" class="strong">Due Date</label>
        @gitbucket.core.helper.html.datepicker("dueDate", milestone.flatMap(_.dueDate))
        <span id="error-dueDate" class="error"></span>
      </fieldset>
      <hr>
      <div class="pull-right">
        @if(milestone.isEmpty){
          <input type="submit" class="btn btn-success" value="Create milestone"/>
        } else {
          @if(milestone.get.closedDate.isDefined){
            <input type="button" class="btn btn-default" value="Open" id="open" onclick="location.href='@helpers.url(repository)/issues/milestones/@milestone.get.milestoneId/open';"/>
          } else {
            <input type="button" class="btn btn-default" value="Close" id="close" onclick="location.href='@helpers.url(repository)/issues/milestones/@milestone.get.milestoneId/close';"/>
          }
          <input type="submit" class="btn btn-success" value="Update milestone"/>
        }
      </div>
    </form>
  }
}
